package com.sx.cms.dao.impl;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.sx.cms.dao.IUserInfoDao;
import com.sx.cms.entity.UserInfoEntity;
import com.sx.core.BaseDao;

public class UserInfoDao extends BaseDao implements IUserInfoDao {
	private Log log = LogFactory.getLog(this.getClass());
	
	/* (non-Javadoc)
	 * @see com.sx.cms.dao.IUserInfoDao#getUserInfoForLogin(com.sx.cms.entity.UserInfoEntity)
	 */
	public UserInfoEntity getUserInfoForLogin(UserInfoEntity userinfo) {
		UserInfoEntity user = null;
		try {
			user = (UserInfoEntity)getSqlMapClientTemplate().queryForObject("CMSUserInfo.getUserInfoForLogin",userinfo);
		} catch (Exception e) {
			log.error("查询用户信息",e);
		}
		return user;
	}
	/* (non-Javadoc)
	 * @see com.sx.cms.dao.IUserInfoDao#findUserInfoEntity(com.sx.cms.entity.UserInfoEntity)
	 */
	public UserInfoEntity findUserInfoEntity(UserInfoEntity userinfo) {
		UserInfoEntity user = null;
		try {
			user = (UserInfoEntity)getSqlMapClientTemplate().queryForObject("CMSUserInfo.findUserInfo",userinfo);
		} catch (Exception e) {
			log.error("查询用户信息",e);
		}
		return user;
	}
	/**
	 *验证用户是否存在 
	 **/
	public void isUserAvaliable(){
		String str = "";
		try {
			
		} catch (Exception e) {
			log.error("验证用户是否存在",e);
		}
	}
	/**
	 *注册用户 
	 **/
	public Integer addUserInfo(UserInfoEntity userinfo) {
		Integer id = null;
		try {
			id = super.addInfo(userinfo, "CMSUserInfo.addInfo");
		} catch (Exception e) {
			// TODO: handle exception
			log.error("新增用户信息",e);
		}
		return id;
	}

	public boolean editUserInfo(UserInfoEntity userinfo) {
		boolean flag = false;
		try {
			flag = super.updateInfo(userinfo, "");
		} catch (Exception e) {
			// TODO: handle exception
			log.error("编辑用户信息",e);
		}
		return flag;
	}

}
